package me.ree.zkproduct.listener;

import lombok.extern.slf4j.Slf4j;
import me.ree.zkproduct.event.MyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MyEventListener implements ApplicationListener {
    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        log.info("MyEventListener onApplicationEvent begin, class name is: {}", event.getClass().getName());
        if (event.getClass() == MyEvent.class) {
            log.info("MyEventListener: My event has been accepted");
            log.info("MyEventListener: My event message: {}", ((MyEvent) event).getMessage());
        }
    }
}
